package com.sharing.controller;

import com.sharing.common.Page;
import com.sharing.common.Result;
import com.sharing.domain.UserProduction;
import com.sharing.service.UserProductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/userProduction")
public class UserProductionController {

    @Autowired
    private UserProductionService userProductionService;

    /**
     * 根据用户id查询评论信息
     * @param userId
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/userId")
    public Result<Page<UserProduction>> selectContentByUserId(Integer userId, Integer page, Integer size) {
        return userProductionService.selectContentByUserId(userId, page, size);
    }

    /**
     * 根据id查询作品信息
     * @param id
     * @return
     */
    @GetMapping
    public Result<UserProduction> selectContentById(Integer id) {
        return userProductionService.selectUserProductionById(id);
    }

    /**
     * 根据主键删除评论
     * @param id
     * @return
     */
    @DeleteMapping
    public Result<Integer> deleteContent(Integer id) {
        return userProductionService.deleteContent(id);
    }

    /**
     * 修改作品
     * @param userProduction
     * @return
     */
    @PostMapping("/update")
    public Result<Integer> updateContent(@RequestBody UserProduction userProduction) {
        return userProductionService.updateContent(userProduction);
    }

    /**
     * 新增作品
     * @param userProduction
     * @return
     */
    @PostMapping("/insert")
    public Result<UserProduction> insertContent(@RequestBody UserProduction userProduction) {
        return userProductionService.insertContent(userProduction);
    }
}
